package com.qishon.pc.domain.model;

import java.util.List;


import lombok.Data;


@Data
public class MasPartAssemply {

    /**
     * 部件Key
     */
    private Long assemplyKey;

    /**
     * 部件名称
     */
    private String assemplyName;

    /**
     * 部件编码
     */
    private String assemplyCode;

    /**
     * 部件序号
     */
    private String seq;

    /**
     * 部件是否可选
     */
    private Boolean isChangeable;

    /**
     * 默认部件
     */
    private Boolean isDefault;

    /**
     * 选中部件
     */
    private Boolean isSelected;

    /**
     * 部件缩略图URL
     */
    private String thumbsFilePath;

    /**
     * 部件
     */
    private List<MasPartFabric> masPartFabrics;

    /**
     * 获取默认面料
     */
    public MasPartFabric getDefaultFabric() {
        MasPartFabric fabric = null;
        for (MasPartFabric masPartFabric : masPartFabrics) {
            if (masPartFabric.getIsDefault() != null && masPartFabric.getIsDefault()) {
                fabric = masPartFabric;
                break;
            }
        }
        if (fabric == null && masPartFabrics != null) {
            fabric = masPartFabrics.get(0);
        }
        return fabric;
    }


}
